package com.sykj.common;

import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;

public class ShiroRealm2 extends AuthorizingRealm {

//	@Autowired
//	IUserSevice userService;
	
//	登录认证方法
	@Override
	protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken arg0) throws AuthenticationException {
		return null;
//		UsernamePasswordToken token = (UsernamePasswordToken) arg0;
//		User userByName = userService.getUserByName(token.getUsername());
//		SimpleAuthenticationInfo info;
//		if (userByName==null) {
//			throw new UnknownAccountException("该用户不存在");
//		}
//		
//		String name = getName();
////		创建认证信息对象
////		info = new SimpleAuthenticationInfo(userByName.getBname(),userByName.getPwd(),name);
//		ByteSource byteSource = ByteSource.Util.bytes(userByName.getBname());
//		info = new SimpleAuthenticationInfo(userByName.getBname(),userByName.getPwd(),byteSource,name);
//		
//		return info;//认证信息对象
	}
////	授权接口实现
//@Override
   protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) {
//// 创建角色集合
//	Set<String> roles = new HashSet<>();
////	获取登陆者名称
//	Object prin = arg0.getPrimaryPrincipal();
////	用户名为tom设为管理员
//	if (prin.equals("tom")) {
//		roles.add("admin");//添加管理员角色
//	}
////	用户名为Jack设置为用户角色
//	if (prin.equals("look")) {
//		roles.add("user");
//	}
////	System.out.println("角色：" + roles);
////	创建简单的角色信息对象，并返回
//	SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(roles);
	
	return null;
}

}
